10 '----------- MUSICAL ORGAN SIMULATION ------------
30 '
40 KEY OFF: CLS : LOCATE , 25
50 DEFINT A-Z
60 PRINT CHR$(14); " MUSICAL ORGAN SIMULATION "; CHR$(14)
70 PRINT
72 '
75 '----------- PUT UP VIDEO DISPLAY --------------
77 '
80 PRINT "THIS PROGRAM ALLOWS YOUR COMPUTER TO MIMIC ";
90 PRINT "IN A SIMPLE WAY THE OPERATION OF"
100 PRINT "A MUSICAL ORGAN. ALTHOUGH THE PC IS ";
110 PRINT "OBVIOUSLY NO MATCH FOR A $250,000 PIPE"
120 PRINT "ORGAN, IT CAN PRODUCE A VARIETY OF ENTER";
130 PRINT "TAINING SOUNDS. THE TOP ROW OF KEYS"
140 PRINT "SPANS C5-C6, THE SECOND ROW C4-C5. HITTING";
150 PRINT " THE SPACEBAR SHIFTS ALL KEYS UP OR"
160 PRINT "DOWN ONE OCTAVE FOR A TOTAL RANGE OF C4-C7. TREMOLO ";
170 PRINT "CAN BE TURN ON OR OFF BY"
180 PRINT "PRESSING THE CARRIAGE RETURN, WHILE NOTE ";
190 PRINT "DURATION CAN BE ADJUSTED IN 0.1-SEC."
200 PRINT "INCREMENTS BY MEANS OF THE < AND > ";
210 PRINT "KEYS (UNSHIFTED).";
230 H$ = STRING$(3, 205): T$ = CHR$(196)
240 X$ = CHR$(179): F$ = STRING$(3, 196)
250 LOCATE 11, 32: PRINT "KEY ASSIGNMENTS";
260 LOCATE 12, 13: PRINT CHR$(201);
270 FOR I = 1 TO 12: PRINT H$; CHR$(209); : NEXT
280 PRINT H$; CHR$(187);
290 LOCATE 13, 13: PRINT CHR$(186);
310 PRINT TAB(65); CHR$(186);
320 LOCATE 14, 13: PRINT CHR$(204);
330 FOR I = 1 TO 12: PRINT H$; CHR$(216); : NEXT
340 PRINT H$; CHR$(185)
350 LOCATE 15, 13: PRINT CHR$(186);
370 PRINT TAB(65); CHR$(186);
380 LOCATE 16, 13: PRINT CHR$(199);
390 FOR I = 1 TO 12: PRINT F$; CHR$(197); : NEXT
400 PRINT F$; CHR$(182);
410 LOCATE 17, 13: PRINT CHR$(186);
430 PRINT TAB(65); CHR$(186);
440 LOCATE 18, 13: PRINT CHR$(200);
450 FOR I = 1 TO 12: PRINT H$; CHR$(207); : NEXT
460 PRINT H$; CHR$(188);
470 LOCATE 13, 15
480 PRINT "C"; TAB(19); "C#"; TAB(23); "D"; TAB(27); "D#";
490 PRINT TAB(31); "E"; TAB(35); "F"; TAB(39); "F#";
500 PRINT TAB(43); "G"; TAB(47); "G#"; TAB(51); "A";
510 PRINT TAB(55); "A#"; TAB(59); "B"; TAB(63); "C";
520 LOCATE 15, 14: PRINT "ESC";
530 FOR I = 1 TO 9: PRINT TAB(4 * I + 15); CHR$(I + 48); : NEXT
540 PRINT TAB(55); "0"; TAB(59); "-"; TAB(63); "=";
550 LOCATE 17, 14
560 PRINT "TAB"; TAB(19); "Q"; TAB(23); "W"; TAB(27); "E";
570 PRINT TAB(31); "R"; TAB(35); "T"; TAB(39); "Y";
580 PRINT TAB(43); "U"; TAB(47); "I"; TAB(51); "O";
590 PRINT TAB(55); "P"; TAB(59); "["; TAB(63); "]";
591 FOR I = 17 TO 61 STEP 4: LOCATE 13, I: PRINT X$; : NEXT
592 FOR I = 17 TO 61 STEP 4: LOCATE 15, I: PRINT X$; : NEXT
593 FOR I = 17 TO 61 STEP 4: LOCATE 17, I: PRINT X$; : NEXT
594 LOCATE 20, 1: PRINT CHR$(218); STRING$(5, 196); CHR$(191);
595 PRINT TAB(72); CHR$(218); STRING$(7, 196); CHR$(191);
596 LOCATE 21, 1: PRINT X$; "SHIFT"; X$; TAB(72); X$; "TREMOLO"; X$;
597 LOCATE 22, 1: PRINT CHR$(192); STRING$(5, 196); CHR$(217);
598 PRINT TAB(72); CHR$(192); STRING$(7, 196); CHR$(217);
600 LOCATE 20, 30
610 FOR I = 1 TO 9: PRINT TAB(2 * I + 28); CHR$(48 + I); : NEXT
615 PRINT TAB(48); "10";
620 LOCATE 20, 38: COLOR 31, 0: PRINT "5"; : COLOR 7, 0
630 LOCATE 21, 30: PRINT CHR$(212);
640 FOR I = 1 TO 8: PRINT CHR$(205); CHR$(207); : NEXT
650 PRINT CHR$(205); CHR$(190);
660 LOCATE 22, 31: PRINT CHR$(27); " NOTE DURATION "; CHR$(26);
670 LOCATE 25, 15: PRINT "* WHEN YOU HAVE FINISHED, PRESS ";
680 PRINT "B TO ENTER BASIC *";
690 '
700 '---------------- INITIALIZE -------------------
710 '
720 TREMOLO = 1 ' 1=TREMOLO OFF, -1=TREMOLO ON
730 SHIFT = 1   ' 1=NO SHIFT, 2=UPWARD SHIFT OF ONE OCTAVE
740 B = 5: D = 9' CORRESPOND TO 0.5-SEC. INITIALIZE DURATION
750 PLAY "MB"   ' SET UP BUFFER FOR NOTES
760 '
770 '----------- LOOP TO READ KEYBOARD -------------
780 '
800 V$ = INPUT$(1)
810 IF V$ = CHR$(27) THEN F = 523: GOSUB 2000: GOTO 800
820 IF V$ = "1" THEN F = 554: GOSUB 2000: GOTO 800
830 IF V$ = "2" THEN F = 587: GOSUB 2000: GOTO 800
840 IF V$ = "3" THEN F = 622: GOSUB 2000: GOTO 800
850 IF V$ = "4" THEN F = 659: GOSUB 2000: GOTO 800
860 IF V$ = "5" THEN F = 698: GOSUB 2000: GOTO 800
870 IF V$ = "6" THEN F = 740: GOSUB 2000: GOTO 800
880 IF V$ = "7" THEN F = 784: GOSUB 2000: GOTO 800
890 IF V$ = "8" THEN F = 831: GOSUB 2000: GOTO 800
900 IF V$ = "9" THEN F = 880: GOSUB 2000: GOTO 800
910 IF V$ = "0" THEN F = 932: GOSUB 2000: GOTO 800
920 IF V$ = "-" THEN F = 988: GOSUB 2000: GOTO 800
930 IF V$ = "=" THEN F = 1047: GOSUB 2000: GOTO 800
935 IF V$ = CHR$(9) THEN F = 262: GOSUB 2000: GOTO 800
940 IF V$ = "q" OR V$ = "Q" THEN F = 277: GOSUB 2000: GOTO 800
950 IF V$ = "w" OR V$ = "W" THEN F = 294: GOSUB 2000: GOTO 800
960 IF V$ = "e" OR V$ = "E" THEN F = 311: GOSUB 2000: GOTO 800
970 IF V$ = "r" OR V$ = "R" THEN F = 330: GOSUB 2000: GOTO 800
980 IF V$ = "t" OR V$ = "T" THEN F = 349: GOSUB 2000: GOTO 800
990 IF V$ = "y" OR V$ = "Y" THEN F = 370: GOSUB 2000: GOTO 800
1000 IF V$ = "u" OR V$ = "U" THEN F = 392: GOSUB 2000: GOTO 800
1010 IF V$ = "i" OR V$ = "I" THEN F = 415: GOSUB 2000: GOTO 800
1020 IF V$ = "o" OR V$ = "O" THEN F = 440: GOSUB 2000: GOTO 800
1030 IF V$ = "p" OR V$ = "P" THEN F = 466: GOSUB 2000: GOTO 800
1040 IF V$ = "[" OR V$ = "{" THEN F = 494: GOSUB 2000: GOTO 800
1050 IF V$ = "]" OR V$ = "}" THEN F = 523: GOSUB 2000: GOTO 800
1060 IF V$ = CHR$(32) THEN GOSUB 2500: GOTO 800'SHIFT W/SPACEBAR
1065 '   IN LINE BELOW < AND > CAUSE DURATION TO BE SET
1070 IF V$ = CHR$(44) OR V$ = CHR$(46) THEN GOSUB 3000: GOTO 800
1080 IF V$ = CHR$(13) THEN GOSUB 3500: GOTO 800'CR=TREMOLO ON/OFF
1090 IF V$ = "b" OR V$ = "B" THEN CLS : END
1110 GOTO 800
1120 END
1130 '
1140 '--------- SUBROUTINE TO SOUND A NOTE ---------
1150 '
1155 '
2000 SOUND 100, 0: F = F * SHIFT
2010 IF TREMOLO = 1 THEN SOUND F, D: RETURN
2015 N = .33 * D: IF N < 1 THEN N = 1
2020 DELTA = .012 * F: F1 = F + DELTA: F2 = F - DELTA
2025 '--- TREMOLO LOOP ---
2030 FOR I = 1 TO N
2040    SOUND F1, 1: SOUND F, 1: SOUND F2, 1
2050 NEXT I
2060 RETURN
2470 '
2480 '---- SUBROUTINE TO SET OCTAVE-SHIFT FLAG -----
2490 '
2500 SHIFT = INT(1 + (1 / SHIFT))
2510 IF SHIFT = 1 THEN COLOR 7, 0 ELSE COLOR 0, 7
2520 LOCATE 21, 2: PRINT "SHIFT": COLOR 7, 0
2530 RETURN
2970 '
2980 '----- SUBROUTINE TO SET NOTE DURATION -------
2990 '
3000 C = B: IF V$ = CHR$(46) THEN B = B + 1 ELSE B = B - 1
3010 IF B > 10 THEN B = 10
3020 IF B < 1 THEN B = 1
3030 LOCATE 20, (2 * C + 28)
3035 IF C < 10 THEN PRINT CHR$(C + 48) ELSE PRINT "10"
3040 COLOR 31, 0: LOCATE 20, (2 * B + 28)
3050 IF B < 10 THEN PRINT CHR$(B + 48) ELSE PRINT "10"
3060 COLOR 7, 0: D = B * 1.8
3070 RETURN
3470 '
3480 '----- SUBROUTINE TO SET TREMOLO FLAG ----------
3490 '
3500 TREMOLO = -TREMOLO
3510 IF TREMOLO = 1 THEN COLOR 7, 0 ELSE COLOR 0, 7
3520 LOCATE 21, 73: PRINT "TREMOLO": COLOR 7, 0
3530 RETURN


